package com.longcai.controller.exchange;

import com.alibaba.fastjson.JSONObject;
import com.longcai.bean.ApiResult;
import com.longcai.service.exchange.ClyjExchangeMallService;
import com.longcai.util.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * <p>
 * 兑换商城（积分商城，红包商城） 前端控制器
 * </p>
 *
 * @author kh
 * @since 2019-04-15
 */
@Controller
@RequestMapping("/clyjExchangeMallWeb")
public class ClyjExchangeMallController {

    private static Logger logger = LoggerFactory.getLogger(ClyjExchangeMallController.class);
    @Autowired
    private ClyjExchangeMallService clyjExchangeMallService;

    /**
     * 获取展示列表
     */
    @RequestMapping("/exchangeMallList")
    @ResponseBody
    public ApiResult<?> getExchangeMallList(@RequestBody JSONObject param) {
        if (StringUtils.isEmpty(param.getString("type")) || StringUtils.isEmpty(param.getString("page")) || StringUtils.isEmpty(param.getString("size"))) {
            logger.error("参数非法" + "type:" + param.getString("type") + "--------"
                    + "page:" + param.getString("page") + "--------"
                    + "size:" + param.getString("size") + "--------"
            );
            ApiResult.fail("参数非法");
        }
        ApiResult<?> r = clyjExchangeMallService.queryExchangeMallList(param.getString("type"), param.getString("page"), param.getString("size"));
        return r;
    }
}

